home *** CD-ROM | disk | FTP | other *** search
/ Atari Forever 4 / Atari Forever 4 / Atari Forever 4.iso / SERIE_AI / AI_017 / INTERNET.TOS / SOFTWARE / TUWTCPSR / ICMP.H < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-04  |  2.7 KB  |  78 lines

  1.  
  2. #ifndef _INET_ICMP
  3. #define _INET_ICMP
  4.  
  5.  
  6. #ifndef _INET_PKT
  7. #include "pktdrv.h"
  8. #endif
  9.  
  10. #ifndef _INET_IP
  11. #include "ip.h"
  12. #endif
  13.  
  14. #define MAXICMP    300
  15. #define ECHO_TIMEOUT    6
  16.                                 /* icmp_types */
  17. #define ICMP_ECHOREP    0        /* ICMP Echo reply */
  18. #define ICMP_DESTIN        3        /* Destination Unreachable */
  19. #define ICMP_SOURCEQ    4        /* Source quench */
  20. #define ICMP_REDIR        5        /* Redirect */
  21. #define ICMP_ECHOREQ    8        /* ICMP Echo request */
  22. #define ICMP_TIMEX        11        /* Time exceeded */
  23. #define ICMP_PARAM        12        /* Parameter problem */
  24. #define ICMP_TIMEREQ    13        /* Timestamp request */
  25. #define ICMP_TIMEREP    14
  26. #define ICMP_INFO        15        /* Information request */
  27. #define ICMP_SUBNETREQ    17        /* subnet mask request */
  28. #define ICMP_SUBNETREP    18        /* subnet mask reply   */
  29.  
  30.  
  31. #define    ICMP_DSTNET        0        /* icmp codes */
  32. #define    ICMP_DSTHOST    1
  33. #define    ICMP_DSTPROT    2
  34. #define    ICMP_DSTPORT    3
  35. #define    ICMP_DSTFRAG    4
  36. #define    ICMP_DSTSRC        5
  37.  
  38. #define REDIRTABLEN        10
  39.  
  40. struct redent
  41. {
  42.     INADDR    dst_inaddr;
  43.     INADDR    gw_inaddr;
  44. };
  45.  
  46. extern struct redent redtab[];
  47.  
  48. typedef struct
  49. {
  50.     u_char    type;                /* ICMP type field */
  51.     u_char    code;                /* ICMP code field */
  52.     u_short chksum;                /* checksum */
  53.     u_short    part1;
  54.     u_short part2;        /* depends on type and code */
  55. }ICMP;
  56.  
  57.  
  58.  
  59. struct ping 
  60. {                /* ICMP Echo request/reply header */
  61.     u_char    ptype;
  62.     u_char    pcode;
  63.     u_short pchksum;
  64.     u_short pid;
  65.     u_short pseq;
  66. };
  67.  
  68.  
  69. #define    PGNOSND        0    /* Couldn't send pkt */
  70. #define    PGTMO        1    /* timedout */
  71. #define    PGBADDATA    2    /* rcved bad data back */
  72. #define    PGWAITING    3    /* waiting for rcpt of packet */
  73. #define    PGSUCCESS    4    /* success */
  74.  
  75.  
  76. /* structure of an icmp destination unreachable packet */
  77.  
  78. struct destun  
  79. {
  80.     u_char    dtype;
  81.     u_char    dcode;
  82.     u_short dchksum;
  83.     u_short dno1;
  84.     u_short dno2;
  85.     IP        dip;
  86.     char    ddata[8];
  87. };
  88.  
  89. /* structure of an icmp time exceeded packet */
  90.  
  91. struct timex  
  92. {
  93.     u_char    ttype;
  94.     u_char    tcode;
  95.     u_short tchksum;
  96.     u_short tno1;
  97.     u_short tno2;
  98.     IP        tip;
  99.     char    tdata[8];
  100. };
  101.  
  102. /* structure of a timestamp reply */
  103.  
  104. struct tstamp 
  105. {
  106.     u_char    ttype;
  107.     u_char    tcode;
  108.     u_short txsum;
  109.     u_short tid;
  110.     u_short tseq;
  111.     long    tstamp[3];
  112. };
  113.  
  114. /* structure of an icmp redirect */
  115.  
  116. struct redirect
  117. {
  118.     u_char    rdtype;
  119.     u_char    rdcode;
  120.     u_short rdchksum;
  121.     INADDR    rdgw;
  122.     IP        rdip;
  123.     char    rddata[8];
  124. };
  125.  
  126. /* structure of netmask lookup */
  127.  
  128. struct netmask
  129. {
  130.     u_char    nmtype;
  131.     u_char    nmcode;
  132.     u_short nmchksum;
  133.     u_short nmid;
  134.     u_short    nmseq;
  135.     INADDR    nmmask;
  136. };
  137.  
  138.  
  139. typedef struct
  140. {
  141.     ETH        et;
  142.     IP        ip;
  143.     ICMP    icmp;
  144.     char    icmp_data[MAXICMP];
  145. } ICMP_PACKET;
  146.  
  147. #define ICMP_PKTSIZE    (int)(sizeof(ETH)+sizeof(IP)+sizeof(ICMP))
  148.  
  149.  
  150.  
  151. int icmp_init(void);
  152. int icmp_handler(PACKET *,int,INADDR);
  153. int icmp_dstun(INADDR,IP *,int);
  154. int icmp_ping(INADDR,int);
  155.  
  156. #endif
  157.